﻿#include "backgroundsystem.h"
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlDriver>
#include <QSqlRecord>
#include <QSqlQuery>
#include <QApplication>
#include <QDebug>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    //链接数据库
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("F:/yueqian/sql/db/project/mydb");
    if ( !db.open() ){
        qDebug() << "db.open error "<<db.lastError().text() ;
        return -1;
    }
    //自动去关联到默认连接名的数据库
    QSqlQuery query;
    //创建表格
    if(!query.exec("create table if not exists Personnel_information(Number char(32) primary key,Full_name char(32),Photo char(32),Gender char(32),Telephone char(32),Birth char(32),Time char(32))"))
    {
        qDebug()<<"create error "<<query.lastError().text();
        return -1;
    }
    BackgroundSystem w;
    w.show();
    return a.exec();
}
